package cn.itcast;

import org.junit.Test;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

public class OracleDemo {
    @Test
    public void javaOracle() throws Exception {
        //加载数据库驱动
        Class.forName("oracle.jdbc.driver.OracleDriver");
        //得到Connection连接
        Connection connection=DriverManager.getConnection("jdbc:oracle:thin:@192.168.30.128:1521:orcl","itheima","itheima");
        //得到预编译的Statemen对象
        PreparedStatement pstm=connection.prepareStatement("select * from emp where empno=?");
        //给参数赋值
        pstm.setObject(1,7828);
        //执行数据库查询操作
        ResultSet rs = pstm.executeQuery();
        //输出结果
        while (rs.next()){
            System.out.println("ename");
        }
        //释放资源

        rs.close();
        pstm.close();
        connection.close();
    }
}
